home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Efficient Sorting - In search of
- Date: Wed, 06 Mar 96 00:26:40 GMT
- Organization: none
- Message-ID: <826072000snz@genesis.demon.co.uk>
- References: <4h4imh$3bh@news.cis.nctu.edu.tw> <4h4rgs$f8l@news.Belgium.EU.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4h4rgs$f8l@news.Belgium.EU.net>
- pahint@eunet.be "Pieter Hintjens" writes:
-
- >Don Pierce (don@pierce.geometrics.com) wrote:
- >: I am looking for an efficient sorting algorithm
- >: that can sort an array of floats. I prefer
- >: a non-recursive version as I have heard they are
- >: not very efficient on large data sets. My arrays
- >: are up 10000 elements.
- >
- >Try the COMB SORT algorithm. This is basically a
- >bubble sort, with a one line change that brings it
- >up to the same kind of speed as quicksort.
-
- It is still likely to be slower than any reasonable version of qsort().
-
- Combsort is one of those historical curiosities that has no practical use
- (much like bubble sort really). For small arrays (certainly up to 10000)
- shell sort is better. For anything larger you go to quicksort, heapsort or
- for lists, list merge sort. These are all on average at least twice as fast
- as combsort. Where you have very large arrays and spare space available you
- can use something like radix sort.
-
- >I'd give you the algorithm in code, but my version
- >is in COBOL, and this is a C newsgroup... ;-)
-
- If your qsort() is poor get a decent one e.g. the GNU one or the one in
- Snippets (which is slightly better in my experience).
-
- >Oops, my mistake - it's a *two* line change.
-
- Shell sort is a similar modification of insertion sort. If you're regularly
- sorting lots of data it is worth grabbing code with a better algorithm.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-